<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>   
     <script type="text/javascript" src="../js/jquery-1.9.1.js"></script>
</head>
<body>
    <form action="/register" method="POST" enctype="application/x-www-form-urlencoded">
     <div>用户名：<input type="text" name="user"  id="user"><span class="con"></span></div>
     <div>密码：<input type="password" name="pwd"  ></div>
     <div>密码：<input type="password" name="repwd"  ></div>
    </form>

    <script>
        $(function(){
              $("#user").blur(function(){
              $.ajax({
                      url:"http://localhost:4000/register",
                      type:"post",
                      data:{
                          "username":$("#user").val()
                      },
                      dataType:"json",
                      success:function(data)
                      {
                           $(".con").text(data.msg);
                      },error:function(err)
                      {
                          $(".con").text(err);
                      }
                    })
              })
         })
      
    </script>
</body>
</html>